package com.ai.bitcoin.service.impl;

import com.ai.bitcoin.constant.QrCodeConstant;
import com.ai.bitcoin.jpa.dao.BccWeixinCoinQrcodeDao;
import com.ai.bitcoin.jpa.entity.BccWeixinCoinQrcode;
import com.ai.bitcoin.service.WeixinCoinQrcodeService;
import com.ai.bitcoin.service.helper.WeiXinServiceHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WeixinCoinQrcodeServiceImpl implements WeixinCoinQrcodeService {

    @Autowired
    private BccWeixinCoinQrcodeDao bccWeixinCoinQrcodeDao;

    @Autowired
    private WeiXinServiceHelper weiXinServiceHelper;

    private String[] bccIds = {"1", "1026", "11", "12", "1202", "124", "1386", "1396", "141", "1449", "146", "19", "201", "235", "24", "27", "3", "31", "372", "374", "39", "4", "5", "50", "53", "57", "6", "655", "66", "7", "9", "90","2","10","13","14","18","17","138","22","8"};

    @Override
    public void generateQrcode() {
        for(String bccId : bccIds) {
            String url = weiXinServiceHelper.generatePermanentQrcode(QrCodeConstant.PERMANET_BCC_QRCODE+bccId);
            BccWeixinCoinQrcode qrcode = new BccWeixinCoinQrcode();
            qrcode.setBccId(bccId);
            qrcode.setUrl(url);
            bccWeixinCoinQrcodeDao.save(qrcode);
        }
    }

}
